package netWorkPrograming.tcp.tcp05;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author yangwenqi
 * @decs TODO
 * @date 2025/5/27
 * 需求5：当服务器只是读取消息，客户端写出消息，此时一个服务器可以接收多个客户端
 */
public class ServerDemo {
    public static void main(String[] args) {
        System.out.println("-----------服务端--------------");
        try {
            ServerSocket ss = new ServerSocket(8888);
            System.out.println("服务端监听端口号：8888");
            while (true) {
                Socket socket = ss.accept();
                System.out.println("客户端"+socket.getRemoteSocketAddress()+"已连接！");
                new Thread(new ReaderThread(socket)).start();
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }


    }
}

